Traverse through the ougoing link and read the object Identifier

Hello,

I need to obtain the Object IDs of the outgoing linked objects in the module.

For e.g.: If a module is having Object ID "CCF_3" with outgoing 2 links to different modules(SYS and SW) contains object ID as - SYS_403, SW_112

 

I have obtain those object IDs SYS_403, SW_112 and read their attribute "Object Type".

i am new to DXL and hence not much aware of inbuilt functions 

Please help.


UmangVarshney - Fri Jan 13 07:40:47 EST 2017

Re: Traverse through the ougoing link and read the object Identifier
Mathias Mamsch - Fri Jan 13 07:54:20 EST 2017

There are already LOTS of posts on iterating links on the forum: 

For example here: https://www.ibm.com/developerworks/community/forums/html/topic?id=654cc6f2-e8bd-4602-89d4-3f6ec8021c2a&ps=25

If you got problems with a special code, then post it and we can discuss. 

Regards, Mathias

 

Re: Traverse through the ougoing link and read the object Identifier
PekkaMakinen - Fri Jan 13 07:57:28 EST 2017

You do not have to know DXL as you can do that with DOORS Analysis Wizard. If you need to know how to get the DXL inside a traceability column created by Analysis Wizard, see e.g. https://www-01.ibm.com/support/docview.wss?uid=swg21408085

Re: Traverse through the ougoing link and read the object Identifier
UmangVarshney - Sat Jan 14 05:11:21 EST 2017

Mathias Mamsch - Fri Jan 13 07:54:20 EST 2017

There are already LOTS of posts on iterating links on the forum: 

For example here: https://www.ibm.com/developerworks/community/forums/html/topic?id=654cc6f2-e8bd-4602-89d4-3f6ec8021c2a&ps=25

If you got problems with a special code, then post it and we can discuss. 

Regards, Mathias

 

Thank you so much Mathias, i am accepting this code of yours.

 

Object o = current
Link lnk
// Outlinks can be iterated, since the source is already loaded
  for lnk in all o ->"*" do
  {
    // load target
    ModuleVersion mvTarget = targetVersion lnk
    Module modTarget = data mvTarget
    noError();
    if (null modTarget) modTarget = load(mvTarget,false)
    lastError();
    delete mvTarget

    if (null modTarget) { /* put error handling here! */; continue }  

    // get target object
    Object oTgt = target lnk
    if (null oTgt) { /* put error handling here! */; continue }

    if (isDeleted oTgt) { /* error handling here! */; continue }   

    print "Out: '" (oTgt."Object Text") "'\n"
  }

 

 

I just want to know why we are using this much of  statement(commented) as shown below in the below code.

This code is also working fine.

 

Object o = current
Link lnk
// Outlinks can be iterated, since the source is already loaded
  for lnk in all o ->"*" do
  {
    // load target
    ModuleVersion mvTarget = targetVersion lnk
    Module modTarget = data mvTarget
    //noError();
    //if (null modTarget) modTarget = load(mvTarget,false)
    //lastError();
    //delete mvTarget

   // if (null modTarget) { /* put error handling here! */; continue }  

    // get target object
    Object oTgt = target lnk
    //if (null oTgt) { /* put error handling here! */; continue }

    //if (isDeleted oTgt) { /* error handling here! */; continue }   

    print "Out: '" (oTgt."Object Text") "'\n"
  }

 

Thanks in advance 

Re: Traverse through the ougoing link and read the object Identifier
Mathias Mamsch - Sun Jan 15 09:01:26 EST 2017

UmangVarshney - Sat Jan 14 05:11:21 EST 2017

Thank you so much Mathias, i am accepting this code of yours.

 

Object o = current
Link lnk
// Outlinks can be iterated, since the source is already loaded
  for lnk in all o ->"*" do
  {
    // load target
    ModuleVersion mvTarget = targetVersion lnk
    Module modTarget = data mvTarget
    noError();
    if (null modTarget) modTarget = load(mvTarget,false)
    lastError();
    delete mvTarget

    if (null modTarget) { /* put error handling here! */; continue }  

    // get target object
    Object oTgt = target lnk
    if (null oTgt) { /* put error handling here! */; continue }

    if (isDeleted oTgt) { /* error handling here! */; continue }   

    print "Out: '" (oTgt."Object Text") "'\n"
  }

 

 

I just want to know why we are using this much of  statement(commented) as shown below in the below code.

This code is also working fine.

 

Object o = current
Link lnk
// Outlinks can be iterated, since the source is already loaded
  for lnk in all o ->"*" do
  {
    // load target
    ModuleVersion mvTarget = targetVersion lnk
    Module modTarget = data mvTarget
    //noError();
    //if (null modTarget) modTarget = load(mvTarget,false)
    //lastError();
    //delete mvTarget

   // if (null modTarget) { /* put error handling here! */; continue }  

    // get target object
    Object oTgt = target lnk
    //if (null oTgt) { /* put error handling here! */; continue }

    //if (isDeleted oTgt) { /* error handling here! */; continue }   

    print "Out: '" (oTgt."Object Text") "'\n"
  }

 

Thanks in advance 

Well the first block does, what it says: it "loads the target" module ... If the target module is already open of course the code will work, but this is normally not the case.

Do not comment out the "delete mvTarget" otherwise you will leak the ModuleVersion ... (making your code get slower and slower)

Commenting out the lines with "put error handling here" is also fine, but remember: this code handles the corner cases (deleted target module, no access to target module, stale links etc., deleted target objects, etc.). Normally you will not need the code, but inside a library you will want this code to work always.

Regards, Mathias

 

Re: Traverse through the ougoing link and read the object Identifier
UmangVarshney - Sun Jan 15 23:16:54 EST 2017

Mathias Mamsch - Sun Jan 15 09:01:26 EST 2017

Well the first block does, what it says: it "loads the target" module ... If the target module is already open of course the code will work, but this is normally not the case.

Do not comment out the "delete mvTarget" otherwise you will leak the ModuleVersion ... (making your code get slower and slower)

Commenting out the lines with "put error handling here" is also fine, but remember: this code handles the corner cases (deleted target module, no access to target module, stale links etc., deleted target objects, etc.). Normally you will not need the code, but inside a library you will want this code to work always.

Regards, Mathias

 

thanks for your help